{%include file="header.html"%}
<style>
td {font-weight: bold;}
.firtd {	width: 100px;	padding-right: 10px;	text-align: right;}
textarea {	width: 350px;	height: 100px;}
.jz{margin-left:120px;}
.jh input{width: 20px;}
.jian{display: none; }
.zhong:first-child{width: 100px; padding-right: 10px;  text-align: right;};
</style>
<body>
<div class="fixed-bar">
  <div class="item-title">
    <h3>{%if $sign==1%}添加配送区域{%/if%}{%if $sign==''%}编辑配送区域{%/if%}</h3>
  </div>
</div>
<div class="fixed_bottom">
  <form method="post" action="shipping_area.php" id="aspnetForm" name="form1" enctype="multipart/form-data">
  
    <table style=" width:100%;" cellpadding="0" cellspacing="0" class="table tb-type2">
        <tr>
          <td class="firtd">配送区域名称:</td>
          <td><input type="text" name="shipping_area_name"
          value="{%$aa.shipping_area_name%}" id="name" {%if $aa.shipping_area_id%} disabled="disabled" {%/if%}required>*</td> 
        </tr>
        <tr>
          <td class="firtd"> 货到付款:</td>
            <td>
              <input class="hd" style="width:15px" type="radio" onclick=abc1() name="fee_compute_mode" {%if $fields.5.value== 'by_weight'%}checked=checked{%/if%} value="by_weight">按重量计算 &nbsp;&nbsp;&nbsp;&nbsp;
              <input class="hd" style="width:15px" type="radio" onclick=abc2() name="fee_compute_mode"{%if $fields.5.value== 'by_number' %}checked=checked{%/if%} value="by_number">按商品件数计算 
            </td>
        </tr>
       
         <tr class="zhong">
          <td class="firtd"> 1000克以内费用：</td>
          <td><input type="text" name="{%$fields.0.name%}" value="{%$fields.0.value%}" required></td>
        </tr>
        <tr class="zhong">
          <td class="firtd"> 5000克以内续重每500克费用：</td>
          <td><input type="text" name="{%$fields.2.name%}" value="{%$fields.2.value%}" required></td>
        </tr>
        <tr class="zhong">
          <td class="firtd"> 5001克以上续重500克费用：</td>
          <td><input type="text" name="{%$fields.3.name%}" value="{%$fields.3.value%}" required></td>
        </tr>
       
        <tr class="jian">
          <td class="firtd"> 单件商品费用：</td>
          <td><input type="text" name="{%$fields.1.name%}" value="{%$fields.1.value%}" required></td>
        </tr>
      
        <tr>
          <td class="firtd"> 免费额度:</td>
          <td><input type="text" name="{%$fields.4.name%}" value="{%$fields.4.value%}" required></td>
        </tr>
    
    </table>
    <fieldset style="border:1px solid #DDEEF2">
      <span  style="vertical-align: top">所辖区域 </span>
      <table style="width:900px" align="center">
      <tr>
    <td id="regionCell">
      {%foreach from=$regions item=region key=id%}
      <input type="checkbox" name="regions[]" value="" checked="" /> {%$region.region_name%}&nbsp;&nbsp;
      {%/foreach%}
    </td>
  </tr>
  <tr>
    <td>
        <span  style="vertical-align: top">国家 ：</span>
        <select name="country" id="selCountries" style="width:80px">
         {%foreach $shipping_area_edit item=list key=k%}
         {%if $list.region_type==0%}
          <option value="{%$list.region_id%}">{%$list.region_name%}</option>
          {%/if%}
          {%/foreach%}
        </select>
        <span style="vertical-align: top">省份 ：</span>
        <select name="province" id="selProvinces" onchange="get_diqu('selProvinces','selCities')" style="width:80px">
          {%foreach $shipping_area_edit item=list key=k%}
          {%if $list.region_type==1%}
          <option value='{%$list.region_id%}'>{%$list.region_name%}</option>
          {%/if%}
          {%/foreach%}
        </select>

        <span style="vertical-align: top">城市：</span>
        <select name="city" id="selCities" onchange="get_diqu('selCities','selDistricts')" style="width:80px" required>
          <option value=''>=请选择=</option>
        </select>
        <span  style="vertical-align: top">区/县:</span>
        <select name="district" id="selDistricts" style="width:130px" required>
          <option value=''>=请选择=</option>
        </select>
    </td>
  </tr>
    </table>
    </fieldset>
    <div class='jz'>
      <tr>
        <td class="style1">&nbsp;</td>
        <td>
        <input type="hidden" name='shipping_id' value="{%$shipping_id%}">
          <input type="hidden" name="shipping_area_id" value={%$aa.shipping_area_id%}>
          <input type="hidden" name="act" value="insert" />
          <a href="JavaScript:void(0);" class="btn" onclick="reset()"><span>重置</span></a>
          <a href="JavaScript:void(0);" class="btn" onclick="$('#tj').click()"><span>确认提交</span></a>
        </td>
      </tr>
    <input type="reset" id="cz" style="display: none;">
    <input type="submit" id="tj" style="display:none;";>
    </div>
  </form>
</div>
</body>

<script>
// 重置方法
function reset(){
	$('input').val('');
	$('textarea').text('');
	$('select').val('');
}
// 配送方式
function abc1(){
  $(".jian").hide();
  $(".zhong").show();
}
function abc2(){
  $(".zhong").hide();
  $(".jian").show();
}
$(window).load(function(){
  var sx=$(".hd");
  for(var i=0;i<sx.length;i++){
    if($(sx).eq(i).attr('checked')=='checked'){
      if($(sx).eq(i).val()=="by_weight"){
        $(".jian").hide();
        $(".zhong").show();
      }else if($(sx).eq(i).val()=="by_number"){
        $(".zhong").hide();
        $(".jian").show();
      }
    }
  }
})

//配送区域
$("#name").blur(function(){
var name = $("#name").val();
var id=$("input[name=shipping_id]").val();
  $.post("shipping_area.php",{act:'name',shipping_area_name:name,id:id},function(data){
    if(data==1){
      alert('配送区域名称已存在');
    }
   });
});

</script>
</html>